<?php

/*----------------------------------------------+
|  MaxForum					|
|  ===========================================	|
|  By Majd Almontaser				|
|  Released under the License GNU v3.0		|
|  http://www.Max4Dev.com			|
|  ===========================================	|
|  Ttmtt Team - http://www.liioiil.com		|
+-----------------------------------------------*/

if (!defined('MAX_ON')){
	echo "<h1>ACCESS DENIED</h1>You cannot access this file directly.";
	exit();
}

class Gallery
{
	private	$permissions, $settings;
	
	public function __construct($array)
	{
		$this->permissions	= $array['permissions'];
		$this->settings		= $array['settings'];
	}
	
	public function p($p)
	/************
	Get permission value
	**/
	{
		if (is_array($p))
		{
			$val = true;
			
			foreach ($p as $pp)
			
				if ($this->permissions[$pp] != 1)
				{
					$val = false;
					break;
				}
				
			return $val;
		}
		else
		
			if (isset($this->permissions[$p]))
				
				return ($this->permissions[$p] == 1) ? true : false;
				
			else
			
				return false;
	}
	
	public function setting($s)
	{
		return $this->settings[$s];
	}
	
	#--------------------------------------------------------------
	# Some functions to enhance NB's functions
	#--------------------------------------------------------------
	
		public function template($t, $return = true)
		/**
		Set the current template.
		Return the object for method chaining.
		**/
		{
			$this->template = $t;
			
			if ($return) return $this;
		}
		
		public function hook($h)
		/**
		Run template hook(s)
		**/
		{
			if (func_num_args() > 1)
			
				for ($i = 0; $i < func_num_args(); ++$i)
				{
					$arg = func_get_arg($i);
					template_hook($this->template, $arg);
				}
			
			else
			
				template_hook($this->template, $h);
		}
		
		public function escape_string($val)
		/**
		Quick recursive escape function
		**/
		{
			$return = array();
			
			if (func_num_args() > 1)
			
				for ($i = 0; $i < func_num_args(); ++$i)
				
					$return[] = $this->escape_string(func_get_arg($i));
					
			elseif (is_array($val))
			
				foreach ($val as $key => $value)
				
					$return[$key] = escape_string($value);
			
			else
			
				return escape_string($val);
			
			return $return;
		}
}
?>
